import { Inject } from '@midwayjs/core';
import { CoolController, BaseController } from '@cool-midway/core';
import { CommunityCollectEntity } from '../../entity/collect';
import { CommunityCollectService } from '../../service/collect';
import { BaseSysUserEntity } from '../../../base/entity/sys/user';
import { CommunityPostEntity } from '../../entity/post';

/**
 * 收藏信息
 */
@CoolController({
  api: ['add', 'delete', 'update', 'info', 'list', 'page'],
  entity: CommunityCollectEntity,
  service: CommunityCollectService,
  pageQueryOp: {
    select: ['a.*', 'b.nickName AS userName', 'c.content AS postContent'],
    join: [
      {
        entity: BaseSysUserEntity,
        alias: 'b',
        condition: 'a.userId = b.id',
        type: 'leftJoin',
      },
      {
        entity: CommunityPostEntity,
        alias: 'c',
        condition: 'a.postId = c.id',
        type: 'leftJoin',
      },
    ],
  },
})
export class AdminCommunityCollectController extends BaseController {
  @Inject()
  communityCollectService: CommunityCollectService;
  @Inject()
  ctx;
}
